<?php
/* 
 * @author Luong Trong Hieu
 */
class Account extends Zend_Db_Table {
    protected $_name = "account";
    public function numberOfField()
    {
        return (int)(mysql_num_rows(mysql_query("SELECT * FROM $_name")));
    }
    
 /*   public function getUser($id)
    {
        $id = (int)$id;
        $row = $this->fetchRow('id = '. $id);
        if(!$row)
        {
            return 0;;
        }
        else
        {
            return $row->toArray();
        }
    }

    public function getUserList()
    {
        
    }

    public function getUserPage($page, $offset)
    {
        $count = ($page-1)*$offset;
        $result = $this->fetchAll("status = 'available'", "username", $count, $offset);
        return $result->toArray();
    }

    public function insertUser($username, $password, $fullname,
        $age, $sex,
        $email, $address, $role_id, $type_id, $status)
    {
      if($this->fetchRow("username = '$username'")
          || $this->fetchRow("email = 'email'"))
          return 0;

      $data = array(
          'username' => $username,
          'password' => $password,
          'fullname' => $fullname,
          'age' => $age,
          'sex' => $sex,
          'email' => $email,
          'address' =>$address,
          'role_id' => $role_id,
          'type_id' => $type_id,
          'status' => $status,
          );
      $this->insert($data);
      return 1;
    }

    public function updateUser($id, $username, $password,
        $fullname, $sex,
        $email, $address, $role_id, $type_id, $status)
    {
        if($this->fetchRow("status = 'available' AND id !='$id'
                AND username = '$username'")
          || $this->fetchRow("status = 'available' AND id !='$id'
                AND email = '$email'"))
          return 0;

        if($password == "")
        {
            $data = array(
          'username' => $username,
          'fullname' => $fullname,
         // 'age' => $age,
          'sex' => $sex,
          'email' => $email,
          'address' =>$address,
          'role_id' => $role_id,
          'type_id' => $type_id,
          'status' => $status,
          );
        }
        else
        {
            $data = array(
          'username' => $username,
          'password' => $password,
          'fullname' => $fullname,
         // 'age' => $age,
          'sex' => $sex,
          'email' => $email,
          'address' =>$address,
          'role_id' => $role_id,
          'type_id' => $type_id,
          'status' => $status,
          );
        }
        $this->update($data, 'id = '. $id);
        return 1;
    }

    public function deleteUser($id)
    {
        $data = array('status' => 'deleted');
        $this->update($data, 'id='.$id);
    }
  * 
  */
}
